package everyday;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author: Siantar
 * @Date: 2023-06-02-22:39
 * @Description: 1.0
 */
public class T2559 {
    public int[] vowelStrings(String[] words, int[][] queries) {
        Set<Character> set=new HashSet<Character>(){{add('a');add('e');add('i');add('o');add('u');}};
        int[] prefix = new int[words.length+1];
//        Arrays.fill(prefix,0);
        int[] res = new int[queries.length];
        final int[] index = {1};
        final int[] resIndex = {0};
        Arrays.stream(words).forEach(s -> {
            prefix[index[0]] = set.contains(s.charAt(0)) && set.contains(s.charAt(s.length()-1)) ? prefix[index[0] - 1] + 1 : prefix[index[0] - 1];
            index[0]++;
        });
        Arrays.stream(queries).forEach(q->{
            res[resIndex[0]]=prefix[q[1]]-prefix[q[0]];
            resIndex[0]++;
        });
        return res;
    }

}
